﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MySql.Data;
using MySql.Data.MySqlClient;
using MySQL.Db;

namespace Gollie.Mail.Queue.Service
{
	class Queries
	{
		internal static int CountUnsentMails()
		{
			return (int)(long)(new Query("sp_countunsentmails").Execute());
		}

		internal static ResultSet GetUnsentMails()
		{
			return new Query("sp_getunsentmails").Execute() as ResultSet;
		}

		internal static int SetMailStatusToSent(uint id, DateTime dateSent, QueryCollection queries = null)
		{
			QueryArguments args = new QueryArguments();
			args.Add("p_id", id);
			args.Add("p_date", dateSent);

			Query q = new Query("sp_setsent", args);

			if (queries == null)
				return (int)q.Execute();

			queries.Add(q);

			return -1;
		}
	}
}
